<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui, viewport-fit=cover">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <title>My App</title>
    <link rel="stylesheet" href="../../packages/core/css/framework7.min.css">
    <link rel="stylesheet" href="../../css/framework7-icons.css">
  </head>
  <body>
    <div id="app"></div>
    <template id="app-template">
      <f7-app>
        <f7-view main>
          <f7-page @page:beforeremove="onPageBeforeRemove" @page:beforeout="onPageBeforeOut">
            <f7-navbar title="Sheet Modal"></f7-navbar>
            <f7-block>
              <f7-row tag="p">
                <f7-button class="col" raised sheet-open=".demo-sheet">Open Sheet</f7-button>
                <f7-button class="col" raised @click="createSheet">Create Dynamic Sheet</f7-button>
              </f7-row>
              <p>
                <f7-button class="col" raised @click="sheetOpened = true">Open Via Prop Change</f7-button>
              </p>
            </f7-block>
            <f7-sheet class="demo-sheet" :opened="sheetOpened" @sheet:closed="sheetOpened = false">
              <f7-toolbar>
                <div class="left"></div>
                <div class="right">
                  <f7-link sheet-close>Close</f7-link>
                </div>
              </f7-toolbar>
              <!-- Scrollable sheet content -->
              <f7-page-content>
                <f7-block>
                  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae ducimus dolorum ipsa aliquid accusamus perferendis laboriosam delectus numquam minima animi, libero illo in tempora harum sequi corporis alias ex adipisci.</p>
                  <p>Sunt magni enim saepe quasi aspernatur delectus consectetur fugiat necessitatibus qui sed, similique quis facere tempora, laudantium quae expedita ea, aperiam dolores. Aut deserunt soluta alias magnam. Consequatur, nisi, enim.</p>
                  <p>Eaque maiores ducimus, impedit unde culpa qui, explicabo accusamus, non vero corporis voluptatibus similique odit ab. Quaerat quasi consectetur quidem libero? Repudiandae adipisci vel voluptatum, autem libero minus dignissimos repellat.</p>
                  <p>Iusto, est corrupti! Totam minus voluptas natus esse possimus nobis, delectus veniam expedita sapiente ut cum reprehenderit aliquid odio amet praesentium vero temporibus obcaecati beatae aspernatur incidunt, perferendis voluptates doloribus?</p>
                  <p>Illum id laborum tempore, doloribus culpa labore ex iusto odit. Quibusdam consequuntur totam nam obcaecati, enim cumque nobis, accusamus, quos voluptates, voluptatibus sapiente repellendus nesciunt praesentium velit ipsa illo iusto.</p>
                </f7-block>
              </f7-page-content>
            </f7-sheet>
          </f7-page>
        </f7-view>
      </f7-app>
      
    </template>
    <script>
      var component = {
        data() {
          return {
            sheetOpened: false,
          };
        },
        methods: {
          createSheet() {
            const self = this;
            const $ = self.$$;
            // Create sheet modal
            if (!self.sheet) {
              self.sheet = self.$f7.sheet.create({
                content: `
                  <div class="sheet-modal">
                    <div class="toolbar">
                      <div class="toolbar-inner justify-content-flex-end">
                        <a href="#" class="link sheet-close">Close</a>
                      </div>
                    </div>
                    <div class="sheet-modal-inner">
                      <div class="page-content">
                        <div class="block">
                          <p>This sheet modal was created dynamically</p>
                          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse faucibus mauris leo, eu bibendum neque congue non. Ut leo mauris, eleifend eu commodo a, egestas ac urna. Maecenas in lacus faucibus, viverra ipsum pulvinar, molestie arcu. Etiam lacinia venenatis dignissim. Suspendisse non nisl semper tellus malesuada suscipit eu et eros. Nulla eu enim quis quam elementum vulputate. Mauris ornare consequat nunc viverra pellentesque. Aenean semper eu massa sit amet aliquam. Integer et neque sed libero mollis elementum at vitae ligula. Vestibulum pharetra sed libero sed porttitor. Suspendisse a faucibus lectus.</p>
                        </div>
                      </div>
                    </div>
                  </div>
                `.trim(),
              });
            }
            // Close inline sheet
            if ($('.demo-sheet.modal-in').length > 0) self.$f7.sheet.close('.demo-sheet');
            // Open it
            self.sheet.open();
          },
          onPageBeforeOut() {
            const self = this;
            // Close opened sheets on page out
            self.$f7.sheet.close();
          },
          onPageBeforeRemove() {
            const self = this;
            // Destroy sheet modal when page removed
            if (self.sheet) self.sheet.destroy();
          },
        }
      }
    </script>
    <script src="../../packages/vue/vue.min.js"></script>
    <script src="../../packages/vue/framework7-vue.min.js"></script>
    <script src="../../packages/core/js/framework7.min.js"></script>
    <script>
      var theme = 'ios';
      if (location.href.indexOf('theme=md') >= 0) theme = 'md';
      
      if (Framework7.use) Framework7.use(Framework7Vue, { theme: theme });
      else if (Framework7.Class && Framework7.Class.use) Framework7.Class.use(Framework7Vue, { theme: theme });
      
      var plugin = {
        params: {
          theme: theme,
        }
      };
      
      if (Framework7.use) Framework7.use(plugin);
      else if (Framework7.Class && Framework7.Class.use) Framework7.Class.use(plugin);
      
      if (typeof component === 'undefined') {
        var component = {};
      }
      if (typeof routes === 'undefined') {
        var routes = [];
      }
      component.el = '#app';
      component.template = '#app-template';
      
      new Vue(component);
    </script>
  </body>
</html>